|
|
|
|
|
|
|
solve the puzzle, but here is a quick explanation for those who would like to make the attempt. |
|
|
|
|
|
|
|
|
Figure P7-2 should help you follow the logic. |
|
|
|
|
|
|
|
|
In the following example, the form is wider than it is tall. This means that the radius of the circle will be half the height, or ScaleHeight/2. For a given angle A, the horizontal distance to the center from a point on the circle will be the radius times cos(A). The vertical distance from the center to a point on the circle will be the radius times sin(A). The center of the circle is point (ScaleWidth/2, ScaleHeight/2), so these values will be added to the distance from the center to obtain the position of the point on the form. The ScaleMode parameter for the form is set to pixels because the Polyline API function expects pixel coordinate values. |
|
|
|
|
|
|
|
|
' Polyline Example
' Copyright © 1998 by Desaware Inc. All Rights Reserved
Option Explicit
Private Type POINTAPI
X As Long
y As Long
End Type
Private Declare Function Polyline Lib "gdi32" (ByVal hdc As Long, _
lppt() As POINTAPI, ByVal nCount As Long) As Long
Private PointArray() As POINTAPI
Private CurrentColorIndex As Integer
' We need the Arccos function-arccos(0) is Pi
Private Function Arccos(X As Double)
Arccos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
End Function
' This function divides the circle into points and mixes them up
Private Sub SetupPoints(PointCount As Long, Radius As Long, Xoffset As _
Long, Yoffset As Long)
Dim AngleIncrement As Double
Dim PointNumber As Long
Dim SwapPoint As Long
Dim TempPoint As POINTAPI |
|
|
|
|
|